/*
 * @Description: 全局组件注册
 * @Author: zhangwei
 * @Date: 2023-02-06 17:31:09
 * @LastEditTime: 2023-02-18 22:43:51
 * @LastEditors: zw 775925302@qq.com
 */

import type { App } from "vue";

export const setupDesignerCom = (app: App<Element>): void => {
  const modules = import.meta.glob("./cmps/**/*.vue", { eager: true });
  Object.keys(modules).forEach((path) => {
    // 获取路径中的文件名，去除 .vue 后缀
    const arrs = path.split("/");
    const fileName = arrs[arrs.length - 1];
    const componentName = fileName.substring(0, fileName.length - 4);
    app.component(componentName, modules[path].default);
  });
};
